Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero initialize local variables. #1737

Merged
merged 2 commits into from
Jun 26, 2021

Conversation

kevinbackhouse
Copy link
Collaborator

Fixes #1717.

#1717 is caused by a local variable not being initialized at canonmn_int.cpp, line 2764.

I decided it would be best to systematically add zero initializers for all similar cases. I used this CodeQL query to find them all:

import cpp
import semmle.code.cpp.dataflow.DataFlow

from LocalVariable v, ArithmeticType t, string path, DataFlow::Node source
where
  v = source.asUninitialized() and
  DataFlow::localFlowStep(source, _) and
  t = v.getType().getUnspecifiedType() and
  path = v.getLocation().getFile().getRelativePath()
select v, t, path

There are 90 remaining results in the xmpsdk sub-directory which I did not fix, because I believe that is 3rd party code that we try to avoid changing.

@kevinbackhouse kevinbackhouse linked an issue Jun 22, 2021 that may be closed by this pull request
@kevinbackhouse kevinbackhouse added the forward-to-main Forward changes in a 0.28.x PR to main with Mergify label Jun 22, 2021
Copy link
Member

@hassec hassec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@hassec hassec merged commit a14c6bc into Exiv2:0.27-maintenance Jun 26, 2021
mergify bot pushed a commit that referenced this pull request Jun 26, 2021
* Zero initialize local variables.

* Initialize xmpID_

(cherry picked from commit a14c6bc)

# Conflicts:
#	include/exiv2/types.hpp
#	samples/stringto-test.cpp
#	src/http.cpp
#	src/image.cpp
#	src/pgfimage.cpp
@hassec hassec added this to the v0.27.5 milestone Jun 26, 2021
@hassec hassec added bug refactoring Cleanup / Simplify code -> more readable / robust labels Jun 27, 2021
@clanmills clanmills mentioned this pull request Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug forward-to-main Forward changes in a 0.28.x PR to main with Mergify refactoring Cleanup / Simplify code -> more readable / robust
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unstable outputs of exiv2
2 participants